//
//  GYLockHeadView.m
//  LockManagement
//
//  Created by apple on 2018/7/26.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYLockHeadView.h"
#import "UITextField+GYCursorPosition.h"

@interface GYLockHeadView()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *markLableLeadingMarginCons;
@property (weak, nonatomic) IBOutlet UITextField *searchTF;
@property (weak, nonatomic) IBOutlet UIButton *searchBtn;
@property (weak, nonatomic) IBOutlet UIButton *mapBtn;

@end


@implementation GYLockHeadView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.searchBtn.layer.cornerRadius = 5;
    self.searchBtn.layer.borderWidth = 1;
    self.searchBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    
    self.searchTF.layer.cornerRadius = self.searchTF.height/2;
    self.searchTF.layer.borderWidth = 1;
    self.searchTF.layer.borderColor = [UIColor whiteColor].CGColor;
    self.searchTF.CursorPosition = 34;
}

- (IBAction)headTitleSelect:(UIButton *)sender {
    //1.改变lable的位置
    self.markLableLeadingMarginCons.constant = sender.x;
    
    //通知外界面改变UI
    self.lockHeadSelectCallBack(sender.tag);
    
    [self layoutIfNeeded];
}

/**
 搜索按钮点击事件

 @param sender <#sender description#>
 */
- (IBAction)searchBtnClick:(UIButton *)sender {
    self.searchBtnClcikCallBack(self.searchTF.text);
}

- (IBAction)TFresignFirstResponder:(UITextField *)sender {
    [sender resignFirstResponder];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self endEditing:YES];
}

//- (void)setShowMap:(BOOL)showMap {
//    _showMap = showMap;
//    if (showMap) {
//        //1.改变lable的位置
//        self.markLableLeadingMarginCons.constant = self.mapBtn.x;
//        
//        //通知外界面改变UI
//        self.lockHeadSelectCallBack(2);
//        
//        [self layoutIfNeeded];
//    }
//}
@end
